/* Author : Maisa Nurul Agnia */
package jtk.project4.fleet.screen.AddEditPurchaseOrder;

import java.sql.SQLException;

import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.Po;
import jtk.project4.fleet.event.AddEditPurchaseOrderEvent;
import nl.coderight.jazz.Controller;

public class AddEditPurchaseOrderController extends Controller{
	private FleetModel fleetModel;
	private AddEditPurchaseOrderView addEditPurchaseOrderView;
	
	public void handleEvent(AddEditPurchaseOrderEvent evt) throws SQLException {
		Po po = fleetModel.getPo();
	
		switch (evt.getType()) {
		case SAVE:
			//commit changes		
			System.out.println(po.getPoNo());
			fleetModel.insertPo(po);			
			break;
			
		default:
			propagateEvent(evt);
			break;
		}
	}
	
	@Override
	public void execute() {
		// TODO Auto-generated method stub
	
		fleetModel = (FleetModel) getModel();
		addEditPurchaseOrderView = new AddEditPurchaseOrderView();
		setView(addEditPurchaseOrderView);
		showView();
	}

}
